import {Component} from '@angular/core';
import {ApesField} from '@shared/ui-zorro/src/types/apes-field';
import {ApiService} from '@core/services/http/api.service';
import {Events} from '@core/services/events/Events';
import {ExpressionService} from '@core/services/expression/ExpressionService';
import {SubjectService} from '@core/services/events/subject.service';
import { exists, getO } from '../../../../utils/utils';
import { toNumbers } from '@angular/compiler-cli/src/diagnostics/typescript_version';

@Component({
  selector: 'formly-field-steps',
  template: `
    <apes-steps [apesCurrent]="current">
      <ng-container *ngFor="let steps of stepsList">
        <apes-step  [apesTitle]="steps.title" [apesDescription]="steps.description"></apes-step>
      </ng-container>
    </apes-steps>
  `
})
export class FormlyFieldSteps extends ApesField {

  current: any = 0;
  ctx:any = {};
  stepsList : any[] = [];

  constructor(
    protected apiService: ApiService,
    protected events: Events,
    protected expressionService: ExpressionService,
    protected subject: SubjectService
  ) {
    super(apiService, events, expressionService, subject);
  }

  ngOnInit(): void {
    this.ctx = this.formState;
    this.stepsList = getO(this.to.stepsList);
    this.subject.subscribe(this.ctx, this.subject.event_form_steps,data => {
      this.current = data;
    })
  }

}
